package com.study.english.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.study.english.pojo.vo.SysAdvertisementLogVo;
import com.study.english.result.Result;
import com.study.english.service.ISysAdvertisementLogService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

import com.study.english.domain.SysAdvertisementLog;

import org.springframework.web.bind.annotation.*;

/**
 * @author wf
 * @description 针对表【sys_advertisement_log】的数据库操作Controller
 * @createDate 2024-03-11 15:56:34
 */
@RestController
@RequestMapping("sysAdvertisementLog")
public class SysAdvertisementLogController {

    @Autowired
    private ISysAdvertisementLogService sysAdvertisementLogService;


    /**
     * 新增:
     */
    @PostMapping("addSysAdvertisementLog")
    public Result addSysAdvertisementLog(@RequestBody SysAdvertisementLogVo sysAdvertisementLogVo) {
        sysAdvertisementLogService.addSysAdvertisementLog(sysAdvertisementLogVo);
        return Result.success();

    }


    /**
     * 分页查询:
     */
    @PostMapping("getSysAdvertisementLogPageList")
    public Result getSysAdvertisementLogPageList(@RequestBody SysAdvertisementLogVo sysAdvertisementLogVo) {

        IPage<SysAdvertisementLogVo> page = new Page<>(sysAdvertisementLogVo.getPageNum(), sysAdvertisementLogVo.getPageSize());
        IPage<SysAdvertisementLogVo> list = sysAdvertisementLogService.getSysAdvertisementLogPageList(page, sysAdvertisementLogVo);
        return Result.success(list);
    }


    /**
     * 不分页查询:
     */

    @PostMapping("getSysAdvertisementLogList")
    public Result getSysAdvertisementLogList(@RequestBody SysAdvertisementLogVo sysAdvertisementLogVo) {
        List<SysAdvertisementLogVo> sysAdvertisementLogVoList = sysAdvertisementLogService.getSysAdvertisementLogList(sysAdvertisementLogVo);

        return Result.success(sysAdvertisementLogVoList);
    }

    /**
     * 根据id查询详情:
     */

    @GetMapping("getSysAdvertisementLogById")
    public Result getSysAdvertisementLogById(@RequestParam String id) {
        SysAdvertisementLog sysAdvertisementLog = sysAdvertisementLogService.getSysAdvertisementLogById(id);
        return Result.success(sysAdvertisementLog);
    }

    /**
     * 根据id删除:
     */
    @GetMapping("delSysAdvertisementLog")
    public Result delSysAdvertisementLog(@RequestParam String id) {
        sysAdvertisementLogService.delSysAdvertisementLog(id);
        return Result.success();
    }


    /**
     * 修改:
     */
    @PostMapping("updateSysAdvertisementLog")
    public Result updateSysAdvertisementLog(@RequestBody SysAdvertisementLogVo sysAdvertisementLogVo) {
        sysAdvertisementLogService.updateSysAdvertisementLog(sysAdvertisementLogVo);
        return Result.success();

    }
}
